/**
 * Created by XianTao on 2016/8/1
 * <p/>
 * Copyright (c) 2015-2015
 * Apache License
 * Version 2.0, January 2004
 * http://www.apache.org/licenses/
 */
package org.smartspring.activiti.demo.restcontroller;

import lombok.extern.slf4j.Slf4j;
import org.smartspring.activiti.demo.service.ActivitiHystrixService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class TestRestController {
    @Autowired
    private ActivitiHystrixService activitiHystrixService;

    //------Deployment
    @RequestMapping(value = "/getDeployments")
    public void getDeployments(){
        String result = activitiHystrixService.getRepositoryDeployments();
        log.info("-->result: " + result);
    }

    @RequestMapping(value = "/getDeployment/{deploymentId}")
    public void getDeployment(@PathVariable("deploymentId") String deploymentId){
        String result = activitiHystrixService.getRepositoryDeployment(deploymentId);
        log.info("-->result: " + result);
    }

    @RequestMapping(value = "/createDeployment")
    public void createDeployment(){
        String result = activitiHystrixService.createRepositoryDeployments();
        log.info("-->result: " + result);
    }

    @RequestMapping(value = "/deleteDeployment/{deploymentId}")
    public void deleteDeployment(@PathVariable("deploymentId") String deploymentId){
        String result = activitiHystrixService.deleteRepositoryDeployment(deploymentId);
        log.info("-->result: " + result);
    }

    @RequestMapping(value = "/getResourcesOfRepositoryDeployment/{deploymentId}")
    public void getResourcesOfRepositoryDeployment(@PathVariable("deploymentId") String deploymentId){
        String result = activitiHystrixService.getResourcesOfRepositoryDeployment(deploymentId);
        log.info("-->result: " + result);
    }

    @RequestMapping(value = "/getResourceOfRepositoryDeployment/{deploymentId}/{resourceId:.*}")
    public void getResourceOfRepositoryDeployment(@PathVariable("deploymentId") String deploymentId, @PathVariable("resourceId") String resourceId){
        String result = activitiHystrixService.getResourceOfRepositoryDeployment(deploymentId, resourceId);
        log.info("-->result: " + result);
    }

    @RequestMapping(value = "/getResourceDataOfRepositoryDeployment/{deploymentId}/{resourceId:.*}")
    public void getResourceDataOfRepositoryDeployment(@PathVariable("deploymentId") String deploymentId, @PathVariable("resourceId") String resourceId){
        String result = activitiHystrixService.getResourceDataOfRepositoryDeployment(deploymentId, resourceId);
        log.info("-->result: " + result);
    }

    //-----Process Definitions
    @RequestMapping(value = "/getRepositoryProcessDefinitions")
    public void getRepositoryProcessDefinitions() {
        String result = activitiHystrixService.getRepositoryProcessDefinitions();
        log.info("-->result: " + result);
    }

    @RequestMapping(value = "/getRepositoryProcessDefinition/{processDefinitionId}")
    public void getRepositoryProcessDefinition(@PathVariable("processDefinitionId") String processDefinitionId) {
        String result = activitiHystrixService.getRepositoryProcessDefinition(processDefinitionId);
        log.info("-->result: " + result);
    }
}
